00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef PSSSIM_HPP
00011 #define PSSSIM_HPP
00012 #include "gridpack/component/data_collection.hpp"
00013 #include "gridpack/parser/dictionary.hpp"
00014 #include "gridpack/utilities/string_utils.hpp"
00015 namespace gridpack {
00016 namespace parser {
00017 template <class _data_struct> class PsssimParser
00018 {
00019 public:
00020
00021
00022
00023 explicit PsssimParser()
00024 {
00025 }
00026
00027
00028
00029
00030 virtual ~PsssimParser()
00031 {
00032 }
00033
00034
00035
00036
00037
00038
00039
00040 void extract(_data_struct &data_struct,
00041 gridpack::component::DataCollection *data, int g_id)
00042 {
00043 double rval;
00044 bool bval;
00045
00046
00047 if (!data->getValue(HAS_PSS,&bval,g_id)) {
00048 data->addValue(HAS_PSS, true, g_id);
00049 } else {
00050 data->setValue(HAS_PSS, true, g_id);
00051 }
00052
00053
00054 std::string stmp;
00055 if (!data->getValue(PSS_MODEL, &stmp, g_id)) {
00056 data->addValue(PSS_MODEL, data_struct.model, g_id);
00057 } else {
00058 data->setValue(PSS_MODEL, data_struct.model, g_id);
00059 }
00060
00061
00062 int ival;
00063 if (!data->getValue(PSSSIM_INPUTTYPE,&ival,g_id)) {
00064 data->addValue(PSSSIM_INPUTTYPE, data_struct.psssim_inputtype, g_id);
00065 } else {
00066 data->setValue(PSSSIM_INPUTTYPE, data_struct.psssim_inputtype, g_id);
00067 }
00068
00069
00070 if (!data->getValue(PSSSIM_BUS1,&ival,g_id)) {
00071 data->addValue(PSSSIM_BUS1, data_struct.psssim_bus1, g_id);
00072 } else {
00073 data->setValue(PSSSIM_BUS1, data_struct.psssim_bus1, g_id);
00074 }
00075
00076
00077 if (!data->getValue(PSSSIM_BUS2,&ival,g_id)) {
00078 data->addValue(PSSSIM_BUS2, data_struct.psssim_bus2, g_id);
00079 } else {
00080 data->setValue(PSSSIM_BUS2, data_struct.psssim_bus2, g_id);
00081 }
00082
00083
00084 if (!data->getValue(PSSSIM_BUS3,&ival,g_id)) {
00085 data->addValue(PSSSIM_BUS3, data_struct.psssim_bus3, g_id);
00086 } else {
00087 data->setValue(PSSSIM_BUS3, data_struct.psssim_bus3, g_id);
00088 }
00089
00090
00091 if (!data->getValue(PSSSIM_BUS4,&ival,g_id)) {
00092 data->addValue(PSSSIM_BUS4, data_struct.psssim_bus4, g_id);
00093 } else {
00094 data->setValue(PSSSIM_BUS4, data_struct.psssim_bus4, g_id);
00095 }
00096
00097
00098 if (!data->getValue(PSSSIM_BUS5,&ival,g_id)) {
00099 data->addValue(PSSSIM_BUS5, data_struct.psssim_bus5, g_id);
00100 } else {
00101 data->setValue(PSSSIM_BUS5, data_struct.psssim_bus5, g_id);
00102 }
00103
00104
00105 if (!data->getValue(PSSSIM_BUS6,&ival,g_id)) {
00106 data->addValue(PSSSIM_BUS6, data_struct.psssim_bus6, g_id);
00107 } else {
00108 data->setValue(PSSSIM_BUS6, data_struct.psssim_bus6, g_id);
00109 }
00110
00111
00112 if (!data->getValue(PSSSIM_GAINK,&rval,g_id)) {
00113 data->addValue(PSSSIM_GAINK, data_struct.psssim_gaink, g_id);
00114 } else {
00115 data->setValue(PSSSIM_GAINK, data_struct.psssim_gaink, g_id);
00116 }
00117
00118
00119 if (!data->getValue(PSSSIM_TW,&rval,g_id)) {
00120 data->addValue(PSSSIM_TW, data_struct.psssim_tw, g_id);
00121 } else {
00122 data->setValue(PSSSIM_TW, data_struct.psssim_tw, g_id);
00123 }
00124
00125
00126 if (!data->getValue(PSSSIM_T1,&rval,g_id)) {
00127 data->addValue(PSSSIM_T1, data_struct.psssim_t1, g_id);
00128 } else {
00129 data->setValue(PSSSIM_T1, data_struct.psssim_t1, g_id);
00130 }
00131
00132
00133 if (!data->getValue(PSSSIM_T2,&rval,g_id)) {
00134 data->addValue(PSSSIM_T2, data_struct.psssim_t2, g_id);
00135 } else {
00136 data->setValue(PSSSIM_T2, data_struct.psssim_t2, g_id);
00137 }
00138
00139
00140 if (!data->getValue(PSSSIM_T3,&rval,g_id)) {
00141 data->addValue(PSSSIM_T3, data_struct.psssim_t3, g_id);
00142 } else {
00143 data->setValue(PSSSIM_T3, data_struct.psssim_t3, g_id);
00144 }
00145
00146
00147 if (!data->getValue(PSSSIM_T4,&rval,g_id)) {
00148 data->addValue(PSSSIM_T4, data_struct.psssim_t4, g_id);
00149 } else {
00150 data->setValue(PSSSIM_T4, data_struct.psssim_t4, g_id);
00151 }
00152
00153
00154 if (!data->getValue(PSSSIM_MAXOUT,&rval,g_id)) {
00155 data->addValue(PSSSIM_MAXOUT, data_struct.psssim_maxout, g_id);
00156 } else {
00157 data->setValue(PSSSIM_MAXOUT, data_struct.psssim_maxout, g_id);
00158 }
00159
00160
00161 if (!data->getValue(PSSSIM_MINOUT,&rval,g_id)) {
00162 data->addValue(PSSSIM_MINOUT, data_struct.psssim_minout, g_id);
00163 } else {
00164 data->setValue(PSSSIM_MINOUT, data_struct.psssim_minout, g_id);
00165 }
00166
00167 }
00168
00169
00170
00171
00172
00173
00174
00175 void parse(std::vector<std::string> &split_line,
00176 gridpack::component::DataCollection *data, int g_id)
00177 {
00178 double rval;
00179 bool bval;
00180 int nstr = split_line.size();
00181
00182 if (!data->getValue(HAS_PSS,&bval,g_id)) {
00183 data->addValue(HAS_PSS, true, g_id);
00184 } else {
00185 data->setValue(HAS_PSS, true, g_id);
00186 }
00187
00188
00189 std::string stmp, model;
00190 gridpack::utility::StringUtils util;
00191 model = util.trimQuotes(split_line[1]);
00192 util.toUpper(model);
00193 if (!data->getValue(PSS_MODEL,&stmp,g_id)) {
00194 data->addValue(PSS_MODEL, model.c_str(), g_id);
00195 } else {
00196 data->setValue(PSS_MODEL, model.c_str(), g_id);
00197 }
00198
00199
00200 int ival;
00201 if (nstr > 3) {
00202 if (!data->getValue(PSSSIM_INPUTTYPE,&ival,g_id)) {
00203 data->addValue(PSSSIM_INPUTTYPE,
00204 atof(split_line[3].c_str()), g_id);
00205 } else {
00206 data->setValue(PSSSIM_INPUTTYPE,
00207 atof(split_line[3].c_str()), g_id);
00208 }
00209 }
00210
00211
00212 if (nstr > 4) {
00213 if (!data->getValue(PSSSIM_BUS1,&ival,g_id)) {
00214 data->addValue(PSSSIM_BUS1,
00215 atof(split_line[4].c_str()), g_id);
00216 } else {
00217 data->setValue(PSSSIM_BUS1,
00218 atof(split_line[4].c_str()), g_id);
00219 }
00220 }
00221
00222
00223 if (nstr > 5) {
00224 if (!data->getValue(PSSSIM_BUS2,&ival,g_id)) {
00225 data->addValue(PSSSIM_BUS2,
00226 atof(split_line[5].c_str()), g_id);
00227 } else {
00228 data->setValue(PSSSIM_BUS2,
00229 atof(split_line[5].c_str()), g_id);
00230 }
00231 }
00232
00233
00234 if (nstr > 6) {
00235 if (!data->getValue(PSSSIM_BUS3,&ival,g_id)) {
00236 data->addValue(PSSSIM_BUS3,
00237 atof(split_line[6].c_str()), g_id);
00238 } else {
00239 data->setValue(PSSSIM_BUS3,
00240 atof(split_line[6].c_str()), g_id);
00241 }
00242 }
00243
00244
00245 if (nstr > 7) {
00246 if (!data->getValue(PSSSIM_BUS4,&ival,g_id)) {
00247 data->addValue(PSSSIM_BUS4,
00248 atof(split_line[7].c_str()), g_id);
00249 } else {
00250 data->setValue(PSSSIM_BUS4,
00251 atof(split_line[7].c_str()), g_id);
00252 }
00253 }
00254
00255
00256 if (nstr > 8) {
00257 if (!data->getValue(PSSSIM_BUS5,&ival,g_id)) {
00258 data->addValue(PSSSIM_BUS5,
00259 atof(split_line[8].c_str()), g_id);
00260 } else {
00261 data->setValue(PSSSIM_BUS5,
00262 atof(split_line[8].c_str()), g_id);
00263 }
00264 }
00265
00266
00267 if (nstr > 9) {
00268 if (!data->getValue(PSSSIM_BUS6,&ival,g_id)) {
00269 data->addValue(PSSSIM_BUS6,
00270 atof(split_line[9].c_str()), g_id);
00271 } else {
00272 data->setValue(PSSSIM_BUS6,
00273 atof(split_line[9].c_str()), g_id);
00274 }
00275 }
00276
00277
00278 if (nstr > 10) {
00279 if (!data->getValue(PSSSIM_GAINK,&rval,g_id)) {
00280 data->addValue(PSSSIM_GAINK,
00281 atof(split_line[10].c_str()), g_id);
00282 } else {
00283 data->setValue(PSSSIM_GAINK,
00284 atof(split_line[10].c_str()), g_id);
00285 }
00286 }
00287
00288
00289 if (nstr > 11) {
00290 if (!data->getValue(PSSSIM_TW,&rval,g_id)) {
00291 data->addValue(PSSSIM_TW,
00292 atof(split_line[11].c_str()), g_id);
00293 } else {
00294 data->setValue(PSSSIM_TW,
00295 atof(split_line[11].c_str()), g_id);
00296 }
00297 }
00298
00299
00300 if (nstr > 12) {
00301 if (!data->getValue(PSSSIM_T1,&rval,g_id)) {
00302 data->addValue(PSSSIM_T1,
00303 atof(split_line[12].c_str()), g_id);
00304 } else {
00305 data->setValue(PSSSIM_T1,
00306 atof(split_line[12].c_str()), g_id);
00307 }
00308 }
00309
00310
00311 if (nstr > 13) {
00312 if (!data->getValue(PSSSIM_T2,&rval,g_id)) {
00313 data->addValue(PSSSIM_T2,
00314 atof(split_line[13].c_str()), g_id);
00315 } else {
00316 data->setValue(PSSSIM_T2,
00317 atof(split_line[13].c_str()), g_id);
00318 }
00319 }
00320
00321
00322 if (nstr > 14) {
00323 if (!data->getValue(PSSSIM_T3,&rval,g_id)) {
00324 data->addValue(PSSSIM_T3,
00325 atof(split_line[14].c_str()), g_id);
00326 } else {
00327 data->setValue(PSSSIM_T3,
00328 atof(split_line[14].c_str()), g_id);
00329 }
00330 }
00331
00332
00333 if (nstr > 15) {
00334 if (!data->getValue(PSSSIM_T4,&rval,g_id)) {
00335 data->addValue(PSSSIM_T4,
00336 atof(split_line[15].c_str()), g_id);
00337 } else {
00338 data->setValue(PSSSIM_T4,
00339 atof(split_line[15].c_str()), g_id);
00340 }
00341 }
00342
00343
00344 if (nstr > 16) {
00345 if (!data->getValue(PSSSIM_MAXOUT,&rval,g_id)) {
00346 data->addValue(PSSSIM_MAXOUT,
00347 atof(split_line[16].c_str()), g_id);
00348 } else {
00349 data->setValue(PSSSIM_MAXOUT,
00350 atof(split_line[16].c_str()), g_id);
00351 }
00352 }
00353
00354
00355 if (nstr > 17) {
00356 if (!data->getValue(PSSSIM_MINOUT,&rval,g_id)) {
00357 data->addValue(PSSSIM_MINOUT,
00358 atof(split_line[17].c_str()), g_id);
00359 } else {
00360 data->setValue(PSSSIM_MINOUT,
00361 atof(split_line[17].c_str()), g_id);
00362 }
00363 }
00364 }
00365
00366
00367
00368
00369
00370
00371 void store(std::vector<std::string> &split_line,_data_struct &data)
00372 {
00373
00374 int o_idx;
00375 o_idx = atoi(split_line[0].c_str());
00376 data.bus_id = o_idx;
00377
00378
00379 gridpack::utility::StringUtils util;
00380 std::string tag = util.clean2Char(split_line[2]);
00381 strcpy(data.gen_id, tag.c_str());
00382
00383 std::string sval;
00384
00385 sval = util.trimQuotes(split_line[1]);
00386 util.toUpper(sval);
00387
00388
00389 strcpy(data.model, sval.c_str());
00390
00391 int nstr = split_line.size();
00392
00393 if (nstr > 3) {
00394 data.psssim_inputtype= atof(split_line[3].c_str());
00395 }
00396
00397
00398 if (nstr > 4) {
00399 data.psssim_bus1= atof(split_line[4].c_str());
00400 }
00401
00402
00403 if (nstr > 5) {
00404 data.psssim_bus2 = atof(split_line[5].c_str());
00405 }
00406
00407
00408 if (nstr > 6) {
00409 data.psssim_bus3 = atof(split_line[6].c_str());
00410 }
00411
00412
00413 if (nstr > 7) {
00414 data.psssim_bus4 = atof(split_line[7].c_str());
00415 }
00416
00417
00418 if (nstr > 8) {
00419 data.psssim_bus5 = atof(split_line[8].c_str());
00420 }
00421
00422
00423 if (nstr > 9) {
00424 data.psssim_bus6 = atof(split_line[9].c_str());
00425 }
00426
00427
00428 if (nstr > 10) {
00429 data.psssim_gaink = atof(split_line[10].c_str());
00430 }
00431
00432
00433 if (nstr > 11) {
00434 data.psssim_tw = atof(split_line[11].c_str());
00435 }
00436
00437
00438 if (nstr > 12) {
00439 data.psssim_t1 = atof(split_line[12].c_str());
00440 }
00441
00442
00443 if (nstr > 13) {
00444 data.psssim_t2 = atof(split_line[13].c_str());
00445 }
00446
00447
00448 if (nstr > 14) {
00449 data.psssim_t3 = atof(split_line[14].c_str());
00450 }
00451
00452
00453 if (nstr > 15) {
00454 data.psssim_t4 = atof(split_line[15].c_str());
00455 }
00456
00457
00458 if (nstr > 16) {
00459 data.psssim_maxout = atof(split_line[16].c_str());
00460 }
00461
00462
00463 if (nstr > 17) {
00464 data.psssim_minout = atof(split_line[17].c_str());
00465 }
00466
00467 }
00468 };
00469 }
00470 }
00471 #endif